<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // navigator   => window.navigator

    // userAgent  用户代理信息  通过该属性可以获取浏览器及操作系统信息

    console.log(navigator);
    // console.log(navigator.userAgent);
    // document.write(navigator.userAgent);

    // PC  Windows

    // 移动端 : Android   iPhone   iPad   BB10  


    // 判断是否是移动端?
    var appList = ['Android', 'iPhone', 'iPad', 'BB10'];

    var userAgent = navigator.userAgent;

    var flag = false; //假设不是移动端
    for(var i=0;i<appList.length;i++){
        var app = appList[i];
        if(userAgent.indexOf(app) != -1){
            flag = true;
            break;
        }
    }
    console.log(flag?"移动端:"+app:"PC端");
</script>
</html>